-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorcerers_sequence.java
More file actions
35 lines (34 loc) · 990 Bytes
/
sorcerers_sequence.java
File metadata and controls
35 lines (34 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.*;
import java.util.*;
import java.lang.*;
public class sorcerers_sequence
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int testcase;
testcase=sc.nextInt();
while(testcase--!=0)
{
long n=sc.nextLong();
System.out.print(n+" ");
double temp=n;
while(temp!=1)
{
//2double res;
if(temp%2==0)
{
temp=(long)Math.floor(Math.sqrt(temp));
System.out.print((int)temp+" ");
}
else
{
temp=(long)Math.floor(Math.sqrt(temp)*Math.sqrt(temp)*Math.sqrt(temp));
System.out.print((long)temp+" ");
}
//System.out.print(temp+" ");
}
System.out.print("\n");
}
}
}